const Upload = require('../../libs/upload')

/**
 * 音乐模型
 */
class SongsDemo {
    /**
     * 构造音乐对象
     * @param  {number} id       标识
     * @param  {number} type     类型
     * @param  {string} name     名称
     * @param  {string} copywriter   推荐描述
     * @param  {string} picUrl 封面图片地址
     * @param  {boolean} canDislike    是否可以不喜欢
     * @param  {number} playCount   播放次数
     * @param  {number} trackCount    跟踪次数
     * @param  {boolean} highQuality    是否高质量
     * @param  {string} alg    算法
     * @param  {number} user_id    用户ID
     * @return {SongsDemo}           歌单对象
     */
    constructor(id, type, name, desc, copywriter, picUrl, canDislike, playCount, trackCount, highQuality, alg, total, user_id) {
        this.id = id
        this.type = type
        this.name = name
        this.desc = desc
        this.copywriter = copywriter
        this.picUrl = picUrl
        this.canDislike = canDislike
        this.playCount = playCount
        this.trackCount = trackCount
        this.highQuality = highQuality
        this.alg = alg
        this.total = total
        this.user_id = user_id
    }

    static find(limit = 0) {
        let list = []
        if (limit > 0) {
            list = storage.slice(0, limit)
        } else {
            list = storage
        }

        const new_list = list.map(item => {
            const temp = {}
            Object.assign(temp, item)
            temp.picUrl = Upload.getUrl(temp.picUrl)
            return temp
        })

        return new_list

    }

    static findOne(id) {
        const songsTemp = storage.find(s => s.id === id)
        if (songsTemp) {
            const Songs = {}
            Object.assign(Songs, songsTemp)
            Songs.picUrl = Upload.getUrl(Songs.picUrl)
            return Songs;
        }
        return songsTemp
    }

    delete() {
        return storage.splice(storage.indexOf(this), 1)
    }

    save() {
        storage.indexOf(this) === -1 && storage.push(this)
        return true
    }

    update() {
        return true
    }
}

const storage = [
    new SongsDemo(1, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(2, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(3, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(4, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(5, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(6, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(7, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(7, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(8, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(10, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(11, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(12, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(13, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(14, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(15, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(16, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(17, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(18, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(19, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
    new SongsDemo(20, 0, '中国范', '<span><i>简介：我在二月最后的寒冷里 盼着一抹暖风</i><br></span><span><i>它将裹挟着所有春天的诗意</i><br></span><span><i>向我徐徐吹来</i><br></span><span><i></i><br></span><span><i>Photograhy by Yui Sakai</i></span>', "编辑推荐：樱花酱倾情推荐本周精品新歌", 'jyqj.png', false, 774676, 23, false, "featured", 20, 1),
]

module.exports = SongsDemo